package com.icloud.common.database.enums;

import lombok.Getter;

@Getter
public enum DirectionEnum {
    CREDIT("CREDIT"), // 贷记
    DEBIT("DEBIT"); // 借记

    private final String code;

    DirectionEnum(String code){
        this.code = code;
    }

    public static DirectionEnum byCode(String code) {
        for (DirectionEnum e: DirectionEnum.values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }

    public static boolean isCredit(String code){
        return CREDIT.code.equalsIgnoreCase(code);
    }
    public static boolean isDebit(String code){
        return DEBIT.code.equalsIgnoreCase(code);
    }
}
